home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Unix / Shells / zsh / Source / src / config / bz.define < prev    next >
Encoding:
Text File  |  1994-04-07  |  1.7 KB  |  73 lines

  1. _sym_="$1"
  2. _dfl_="$2"
  3. _des_="$3"
  4. _emp_="$4"
  5. _quo_="$5"
  6.  
  7. _ans_=
  8. while test Z"$_ans_" != Zok
  9. do
  10.   if test -n "$B_query"
  11.   then
  12.      if test -z "$F_define_warned"
  13.      then
  14.      {
  15.        cat <<foo
  16.     * to accept the default (which is inside [brackets]), just press
  17.           Enter/Newline/Return.
  18.     * some questions accept empty answers, they are indicated by
  19.           "(empty ok)" text.
  20.     * to give an empty answer, answer just "none" (but without ""s)
  21.     * do not worry about possible missing "quotes" around your answers,
  22.           they will automagically be added.
  23. foo
  24.      } >&2
  25.        F_define_warned=yep
  26.      fi
  27.      test -z "$B_query"
  28.      {
  29.        echo
  30.        echo "Define $_des_:"
  31.        echo "$_sym_ [$_dfl_] "                | tr -d '\012'
  32.        test -n "$_emp_" && echo "(empty ok) " | tr -d '\012'
  33.        echo "? "                              | tr -d '\012'
  34.      } >&2
  35.      read _ans_
  36.   else
  37.      _ans_=$_dfl_
  38.   fi
  39.   _val_=
  40.   case $_ans_ in
  41.   none ) _val_=
  42.          test -n "$_emp_" && _ans_=ok || _ans_=
  43.          _msg_="$_sym_ is undefined"
  44.      eval $_sym_=
  45.          _ans_=ok
  46.          ;;
  47.   *   )  test -n "$_ans_" && _val_=$_ans_ || _val_=$_dfl_
  48.      if test -z "$_dfl_" -a -z "$_val_"
  49.      then
  50.            _msg_="$_sym_ is empty"
  51.      else
  52.          test Z"$_quo_" = Z'"' && _val_=\"$_val_\"
  53.          test Z"$_quo_" = Z"'" && _val_=\'$_val_\'
  54.            _msg_="$_sym_ is \"$_val_\""
  55.          fi
  56.      eval $_sym_=\"$_val_\"
  57.          _ans_=ok
  58.          ;;
  59.   esac
  60. done
  61.  
  62. test -n "$F_define" && echo "/* $_des_ */"
  63. if test -n "$_val_"
  64. then
  65.   test -n "$F_define" && echo "#define $_sym_ $_val_"
  66. else
  67.   test -n "$F_define" && echo "#undef $_sym_"
  68. fi
  69. {
  70.   echo "    $_msg_..."
  71.   test -n "$B_query" && echo
  72. } >&2
  73.